#!/bin/bash

# 确保脚本以 root 权限运行
if [ "$(id -u)" != "0" ]; then
   echo "该脚本必须以 root 权限运行" 1>&2
   exit 1
fi

systemctl stop firewalld
systemctl disable firewalld

setenforce 0
sed -i 's/^SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config




# 修改 CentOS 仓库配置文件，注释掉 mirrorlist 行
sudo sed -i -e "s|^mirrorlist=|#mirrorlist=|g" /etc/yum.repos.d/CentOS-*.repo

# 修改 CentOS 仓库配置文件，替换 baseurl 为阿里云镜像
sudo sed -i -e "s|^#baseurl=http://mirror.centos.org/\$contentdir/\$releasever|baseurl=https://mirrors.aliyun.com/centos-vault/\$contentdir/\$releasever|g" /etc/yum.repos.d/CentOS-*.repo